import request from '@/utils/request.js'

// 获取省份列表
export function getProvinces() {
  return request({
    url: '/api/areas/provinces',
    method: 'GET'
  })
}

// 获取城市列表
export function getCities(provinceCode) {
  return request({
    url: '/api/areas/cities',
    method: 'GET',
    params: { provinceCode }
  })
}

// 获取区县列表
export function getDistricts(cityCode) {
  return request({
    url: '/api/areas/districts',
    method: 'GET',
    params: { cityCode }
  })
}

// 根据经纬度获取地址信息
export function getAddressByLocation(latitude, longitude) {
  return request({
    url: '/api/geo/reverse',
    method: 'GET',
    params: { latitude, longitude }
  })
}

// 导出locationApi对象
export const locationApi = {
  getProvinces,
  getCities,
  getDistricts,
  getAddressByLocation
} 